package com.ruanyun.modular.admin.service.impl;

import cn.stylefeng.roses.core.reqres.response.ResponseData;
import com.baomidou.mybatisplus.extension.api.R;
import com.ruanyun.base.pojo.page.LayuiPageFactory;
import com.ruanyun.base.consts.PublicCommon;
import com.ruanyun.base.pojo.page.LayuiPageInfo;
import com.ruanyun.modular.admin.entity.*;
import com.ruanyun.modular.admin.mapper.*;
import com.ruanyun.modular.admin.model.result.*;
import com.ruanyun.modular.admin.service.*;
import com.ruanyun.sys.core.shiro.ShiroKit;
import com.ruanyun.modular.admin.model.params.TCommitReportParam;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruanyun.sys.modular.system.entity.User;
import com.ruanyun.sys.modular.system.service.UserService;
import com.ruanyun.util.ExportWordUtils;
import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.tio.utils.jfinal.P;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 报告提交表 服务实现类
 * </p>
 *
 * @author zs
 * @since 2021-04-28
 */
@Service
@Slf4j
public class TCommitReportServiceImpl extends ServiceImpl<TCommitReportMapper, TCommitReport> implements TCommitReportService {
    @Autowired
    private TBasicMaterialMapper tBasicMaterialMapper;
//    @Autowired
//    private TExhaustOutletMapper tExhaustOutletMapper;

    @Autowired
    private TExhaustOrificeMapper exhaustOrificeMapper;

    @Autowired
    private TExhaustEquipmentMapper tExhaustEquipmentMapper;
    @Autowired
    private TMonitoringinfoMapper tMonitoringinfoMapper;
    @Autowired
    private TProductEquipmentMapper tProductEquipmentMapper;
    @Autowired
    private TProductinfoMapper tProductinfoMapper;
    @Autowired
    private TProductionProcessMapper tProductionProcessMapper;
    @Autowired
    private VocManagementLedgerMapper vocManagementLedgerMapper;
    @Autowired
    private TCommitReportMapper reportMapper;
    //    @Autowired
//    private  TProposedMeasuresPlanMapper planMapper;
    @Autowired
    private VocsEmissionMapper vocsEmissionMapper;
    @Autowired
    private UserService userService;

    @Autowired
    private TCommitReportService commitReportService;
    @Autowired
    private TBasicinfoService basicinfoService;
    @Autowired
    private TProductEquipmentService equipmentService;
    @Autowired
    private TMonitoringinfoService monitoringinfoService;
    @Autowired
    private TProductinfoService productinfoService;
    @Autowired
    private TBasicMaterialService materialService;
    @Autowired
    private TProductionProcessService processService;
    @Autowired
    private TExhaustOrificeService exhaustOrificeService;
    @Autowired
    private TPollutantsFactorService pollutantsFactorService;
    @Autowired
    private TExhaustEquipmentService exhaustEquipmentService;
    @Autowired
    private VocsEmissionService emissionService;
    @Autowired
    private TMeasuresService measuresService;
    @Autowired
    private VocManagementLedgerService ledgerService;


    @Override
    public ResponseData add(TCommitReportParam param) {
        TCommitReport entity = getEntity(param);
        entity.setDelFlag(PublicCommon.DEL_FLAG_NORMAL);
        int result = this.baseMapper.insert(entity);
        if (result == 0) {
            return ResponseData.error("添加失败");
        }
        return ResponseData.success();
    }

    @Override
    public void delete(TCommitReportParam param) {
        this.removeById(getKey(param));
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @Override
    public ResponseData updateDelFlagById(Long id) {
        TCommitReport entity = this.baseMapper.selectById(id);
        if (entity == null) {
            return ResponseData.error("该报告提交表不存在");
        }
        entity.setDelFlag(PublicCommon.DEL_FLAG_DELETE);
        int result = this.baseMapper.updateById(entity);
        if (result == 0) {
            return ResponseData.error("删除失败");
        }
        return ResponseData.success();
    }

    @Override
    public ResponseData update(TCommitReportParam param) {
        TCommitReport oldEntity = getOldEntity(param);
        TCommitReport newEntity = getEntity(param);
        ToolUtil.copyProperties(newEntity, oldEntity);
        int result = this.baseMapper.updateById(newEntity);
        if (result == 0) {
            return ResponseData.error("修改失败失败");
        }
        return ResponseData.success();
    }

    @Override
    public TCommitReportResult findBySpec(TCommitReportParam param) {
        return null;
    }

    @Override
    public List<TCommitReportResult> findListBySpec(TCommitReportParam param) {
        return null;
    }

    @Override
    public LayuiPageInfo findPageBySpec(TCommitReportParam param) {
        /*判断当前用户是否为管理员*/
        boolean flag = ShiroKit.isAdmin();
        if (flag != true) {
            User u = userService.getUserInfo();
            if ("1402427539539161089".equals(u.getRoleId())) {//市管理账号
                param.setIsArea("y");
            }

            if ("1402427690353750018".equals(u.getRoleId())) { //县管理账号
                param.setCountyId(String.valueOf(u.getUserId()));
            }

            if ("1162247971007717377".equals(u.getRoleId())) { //企业账号
                param.setCompanyId(userService.getCid());
            }
        }
        Page pageContext = getPageContext();
        IPage page = this.baseMapper.customPageList(pageContext, param);
        return LayuiPageFactory.createPageInfo(page);
    }

    private Serializable getKey(TCommitReportParam param) {
        return param.getId();
    }

    private Page getPageContext() {
        return LayuiPageFactory.defaultPage();
    }

    private TCommitReport getOldEntity(TCommitReportParam param) {
        return this.getById(getKey(param));
    }

    private TCommitReport getEntity(TCommitReportParam param) {
        TCommitReport entity = new TCommitReport();
        ToolUtil.copyProperties(param, entity);
        return entity;
    }

    /**
     * 启用
     *
     * @param id
     * @return
     */
    @Override
    public ResponseData enableById(Long id) {
        TCommitReport entity = this.baseMapper.selectById(id);
        if (entity == null) {
            return ResponseData.error("该报告提交表不存在");
        }
        int result = this.baseMapper.updateById(entity);
        if (result == 0) {
            return ResponseData.error("启用失败");
        }
        return ResponseData.success();
    }

    /**
     * 禁用
     *
     * @param id
     * @return
     */
    @Override
    public ResponseData disableById(Long id) {
        TCommitReport entity = this.baseMapper.selectById(id);
        if (entity == null) {
            return ResponseData.error("该报告提交表不存在");
        }
        int result = this.baseMapper.updateById(entity);
        if (result == 0) {
            return ResponseData.error("禁用失败");
        }
        return ResponseData.success();
    }

    @Override
    public ResponseData commitReport(Integer companyIds) {
        TCommitReport commit = baseMapper.getCommit(companyIds);
        if (commit != null) {
            return ResponseData.error("该条信息已提交,请勿再次提交");
        }
        Long companyId = Long.valueOf(companyIds);
        TCommitReport tCommitReport = new TCommitReport();
        List<Integer> ids = new ArrayList<>();
        String resulIds = null;
        //根据 企业id 查询 信息是否填充完整
        List<TBasicMaterial> tBasicMaterials = tBasicMaterialMapper.getDetails(companyId);
        if (tBasicMaterials.size() != 0) {
            ids = tBasicMaterials.stream().map(TBasicMaterial::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setMaterId(resulIds);
        } else {
            return ResponseData.error("主要原辅料未填写完整");
        }

        List<TExhaustEquipment> tExhaustEquipment = tExhaustEquipmentMapper.getDetails(companyId);
        if (tExhaustEquipment.size() != 0) {
            ids = tExhaustEquipment.stream().map(TExhaustEquipment::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setEquipmentId(resulIds);
        } else {
            return ResponseData.error("废气治理设施未填写完整");
        }


        List<TExhaustOrificeResult> tExhaustOutlet = exhaustOrificeMapper.getDetails(companyId);
        if (tExhaustOutlet.size() != 0) {
            ids = tExhaustOutlet.stream().map(TExhaustOrificeResult::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setExhaustId(resulIds);
        } else {
            return ResponseData.error("废气排放口信息未填写完整");
        }


        //监测信息
        List<TMonitoringinfo> tMonitoringinfo = tMonitoringinfoMapper.getDetails(companyId);
        if (tMonitoringinfo.size() != 0) {
            ids = tMonitoringinfo.stream().map(TMonitoringinfo::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setMonitoringId(resulIds);
        }

        List<TProductEquipment> tProductEquipment = tProductEquipmentMapper.getDetails(companyId);
        if (tProductEquipment.size() != 0) {
            ids = tProductEquipment.stream().map(TProductEquipment::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setPequipmentId(resulIds);
        } else {

            return ResponseData.error("生产设备信息未填写完整");
        }

        List<TProductinfo> tProductinfo = tProductinfoMapper.getDetails(companyId);
        if (tProductinfo.size() != 0) {
            ids = tProductinfo.stream().map(TProductinfo::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setProductId(resulIds);
        } else {
            return ResponseData.error("产品信息未填写完整");
        }

        List<TProductionProcess> tProductionProcess = tProductionProcessMapper.getDetails(companyId);
        if (tProductionProcess.size() != 0) {
            ids = tProductinfo.stream().map(TProductinfo::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setPpId(resulIds);
        } else {
            return ResponseData.error("生产工艺信息未填写完整");
        }

        List<VocManagementLedger> vocManagementLedger = vocManagementLedgerMapper.getDetails(companyId);
        if (vocManagementLedger.size() != 0) {
            ids = vocManagementLedger.stream().map(VocManagementLedger::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setLedgerId(resulIds);
        } else {
            return ResponseData.error("台账信息未填写完整");
        }


//        List<TProposedMeasuresPlan> proposedMeasuresPlans = planMapper.getDetails(companyId);
//        if(proposedMeasuresPlans.size() != 0){
//            ids = proposedMeasuresPlans.stream().map(TProposedMeasuresPlan::getId).collect(Collectors.toList());
//            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
//            tCommitReport.setPlanId(resulIds);
//        } else  {
//            return  ResponseData.error("拟实施措施计划未填写完整");
//        }


        List<VocsEmissionResult> vocsEmissionResults = vocsEmissionMapper.getDetails(companyId);
        if (vocsEmissionResults.size() != 0) {
            ids = vocsEmissionResults.stream().map(VocsEmissionResult::getId).collect(Collectors.toList());
            resulIds = ids.stream().map(String::valueOf).collect(Collectors.joining(","));
            tCommitReport.setEmissionId(resulIds);
        } else {
            return ResponseData.error("vocs排放量未填写完整");
        }
        tCommitReport.setCompanyId(companyIds);
        tCommitReport.setCreateTime(new Date());
        tCommitReport.setDelFlag(1);
        tCommitReport.setIsCommit(2);
        int result = reportMapper.insert(tCommitReport);
        if (result > 0) {
            return ResponseData.success("提交成功");
        } else {
            return ResponseData.error("提交失败");
        }
    }

    @Override
    public ResponseData returnReport(Integer id) {
        TCommitReport commitReport = baseMapper.selectById(id);
        if (id == null) {
            return ResponseData.error("此报告暂未提交");
        }

        int result = baseMapper.deleteById(id);
        if (result > 0) {
            return ResponseData.success();
        }
        return ResponseData.error("请联系管理员");
    }

    @Override
    public TCommitReport getDetailByCid(Integer companyId) {
        return baseMapper.getDetailByCid(companyId);
    }

    @Override
    public Map<String, Object> dataMap(Integer companyId) {

        Map<String, Object> dataMap = new HashMap<>();
        //获取企业基本信息
        TBasicinfoResult basicinfoResult = basicinfoService.getDetail(companyId);


        dataMap.put("countyName", basicinfoResult.getCountyName());
        dataMap.put("companyName", basicinfoResult.getCompanyName());
        dataMap.put("socialCreditCode", basicinfoResult.getSocialCreditCode());
        dataMap.put("companyAddress", basicinfoResult.getCompanyAddress());
        dataMap.put("companyType", basicinfoResult.getCompanyType());
        dataMap.put("ownedPark", basicinfoResult.getOwnedPark());
        dataMap.put("area", basicinfoResult.getArea());
        dataMap.put("longitudeLatitude", basicinfoResult.getLongitudeLatitude());
        dataMap.put("latitude", basicinfoResult.getLatitude());
        if (basicinfoResult.getIdDiscontinued() == 0) {
            dataMap.put("idDiscontinued", "未停产");
        } else {
            dataMap.put("idDiscontinued", "已停产");
        }
        dataMap.put("legalRepresentative", basicinfoResult.getLegalRepresentative());
        dataMap.put("eiaNumber", basicinfoResult.getEiaNumber());
        dataMap.put("pollutionPermitNumber", basicinfoResult.getPollutionPermitNumber());
        dataMap.put("companyPerson", basicinfoResult.getCompanyPerson());
        if (basicinfoResult.getIsFocus() == 0) {
            dataMap.put("isFocus", "是");
        } else {
            dataMap.put("isFocus", "否");
        }
        dataMap.put("pollutionPermitDate", basicinfoResult.getPollutionPermitDate());
        dataMap.put("eiaApproval", basicinfoResult.getEiaApproval());
        dataMap.put("eiaAcceptance", basicinfoResult.getEiaAcceptance());
        dataMap.put("pollutionPermit", basicinfoResult.getPollutionPermit());
        dataMap.put("floorPlan", basicinfoResult.getFloorPlan());
        dataMap.put("businessLicense", basicinfoResult.getBusinessLicense());
        dataMap.put("companyOrganization", basicinfoResult.getCompanyOrganization());


        //获取产品产量信息
        List<TProductinfoResult> productinfoResults = productinfoService.getProDuctList(companyId);

        dataMap.put("productinfoResults", productinfoResults);


        //获取主要原辅料信息
        List<TBasicMaterialResult> materialResults = materialService.getMaterList(companyId);
        dataMap.put("materialResults", materialResults);


        //获取生产设备信息
        List<TProductEquipmentResult> equipmentResults = equipmentService.getEqList(companyId);
        dataMap.put("equipmentResults", equipmentResults);

        //获取生产工艺信息
        List<TProductionProcessResult> processResults = processService.getProcessList(companyId);
        for (TProductionProcessResult processResult : processResults) {
            processResult.setProcessDec(processResult.getProcessDec().replaceAll("<p>", ""));
            processResult.setProcessDec(processResult.getProcessDec().replaceAll("</p>", ""));

        }
        dataMap.put("processResults", processResults);

        //获取废气排放口信息
        List<TExhaustOrificeResult> exhaustOrificeResults = exhaustOrificeService.getExhaustOrificeList(companyId);
        dataMap.put("exhaustOrificeResults", exhaustOrificeResults);

        //有组织排放监测情况
        List<TPollutantsFactorResult> organizatedList = pollutantsFactorService.getOrganizedList(companyId);
        dataMap.put("organizatedList", organizatedList);


        //厂界无组织排放监测情况
        /*上风向*/
        List<TPollutantsFactorResult> unOrganizatedList = pollutantsFactorService.getUnOrganizedList(companyId, 1);
        /*下风向1*/
        List<TPollutantsFactorResult> unOrganizatedList1 = pollutantsFactorService.getUnOrganizedList(companyId, 2);
        /*下风向2*/
        List<TPollutantsFactorResult> unOrganizatedList2 = pollutantsFactorService.getUnOrganizedList(companyId, 3);
        /*下风向3*/
        List<TPollutantsFactorResult> unOrganizatedList3 = pollutantsFactorService.getUnOrganizedList(companyId, 4);

        //封装上风向数据
        String pollutantFactorUp = "";
        String concentrationUp = "";
        String remarkUp = "";
        if (unOrganizatedList.size() != 0) {

            for (TPollutantsFactorResult tPollutantsFactorResult : unOrganizatedList) {
                pollutantFactorUp = pollutantFactorUp + tPollutantsFactorResult.getPollutantFactor() + ",";
                concentrationUp = concentrationUp + tPollutantsFactorResult.getConcentration() + ",";
                remarkUp = remarkUp + tPollutantsFactorResult.getRemark() + ",";

            }

        } else {
            dataMap.put("pollutantFactorUp", "暂无数据");
            dataMap.put("concentrationUp", "暂无数据");
            dataMap.put("remarkUp", "暂无数据");
        }

        dataMap.put("pollutantFactorUp", pollutantFactorUp);
        dataMap.put("concentrationUp", concentrationUp);
        dataMap.put("remarkUp", remarkUp);


        // 封装下风向1数据
        String pollutantFactorDo = "";
        String concentrationDo = "";
        String remarkDo = "";
        if (unOrganizatedList1.size() != 0) {

            for (TPollutantsFactorResult tPollutantsFactorResult : unOrganizatedList1) {
                pollutantFactorDo = pollutantFactorDo + tPollutantsFactorResult.getPollutantFactor() + ",";
                concentrationDo = concentrationDo + tPollutantsFactorResult.getConcentration() + ",";
                remarkDo = remarkDo + tPollutantsFactorResult.getRemark() + ",";

            }

        } else {
            dataMap.put("pollutantFactorDo", "暂无数据");
            dataMap.put("concentrationDo", "暂无数据");
            dataMap.put("remarkDo", "暂无数据");
        }

        dataMap.put("pollutantFactorDo", pollutantFactorDo);
        dataMap.put("concentrationDo", concentrationDo);
        dataMap.put("remarkDo", remarkDo);


        // 封装下风向2数据
        String pollutantFactorDt = "";
        String concentrationDt = "";
        String remarkDt = "";
        if (unOrganizatedList2.size() != 0) {

            for (TPollutantsFactorResult tPollutantsFactorResult : unOrganizatedList2) {
                pollutantFactorDt = pollutantFactorDt + tPollutantsFactorResult.getPollutantFactor() + ",";
                concentrationDt = concentrationDt + tPollutantsFactorResult.getConcentration() + ",";
                remarkDt = remarkDt + tPollutantsFactorResult.getRemark() + ",";

            }

        } else {
            dataMap.put("pollutantFactorDt", "暂无数据");
            dataMap.put("concentrationDt", "暂无数据");
            dataMap.put("remarkDt", "暂无数据");
        }

        dataMap.put("pollutantFactorDt", pollutantFactorDt);
        dataMap.put("concentrationDt", concentrationDt);
        dataMap.put("remarkDt", remarkDt);


        // 封装下风向3数据
        String pollutantFactorDh = "";
        String concentrationDh = "";
        String remarkDh = "";
        if (unOrganizatedList3.size() != 0) {

            for (TPollutantsFactorResult tPollutantsFactorResult : unOrganizatedList3) {
                pollutantFactorDh = pollutantFactorDh + tPollutantsFactorResult.getPollutantFactor() + ",";
                concentrationDh = concentrationDh + tPollutantsFactorResult.getConcentration() + ",";
                remarkDh = remarkDh + tPollutantsFactorResult.getRemark() + ",";

            }

        } else {
            dataMap.put("pollutantFactorDh", "暂无数据");
            dataMap.put("concentrationDh", "暂无数据");
            dataMap.put("remarkDh", "暂无数据");
        }

        dataMap.put("pollutantFactorDh", pollutantFactorDh);
        dataMap.put("concentrationDh", concentrationDh);
        dataMap.put("remarkDh", remarkDh);


        //获取厂内无组织监测情况
        List<TPollutantsFactorResult> positionResults = pollutantsFactorService.getInsidePositionList(companyId);
        dataMap.put("positionResults", positionResults);


        //获取监测信息附件
        List<TMonitoringinfoResult> mResults = monitoringinfoService.getMonList(companyId);
        for (TMonitoringinfoResult mResult : mResults) {
            if (mResult.getMontioringPic() != null) {
                mResult.setMontioringPic(mResult.getMontioringPic().replaceAll(",", "\n"));
            }


        }
        dataMap.put("mResults", mResults);


        //获取企业废气治理设施信息
        List<TExhaustEquipmentResult> exhaustEquipmentResults = exhaustEquipmentService.getExhaustEquipmentList(companyId);

        //修改废气治理设施附件
        for (TExhaustEquipmentResult res : exhaustEquipmentResults) {
            if (res.getEquipmentPhoto() != null) {
                res.setEquipmentPhoto(res.getEquipmentPhoto().replaceAll(",", "\n"));
            }

        }

        dataMap.put("exhaustEquipmentResults", exhaustEquipmentResults);

        //获取VOCs排放量信息
        List<VocsEmissionResult> emissionResults = emissionService.getVocsEmissionList(companyId);
        for (VocsEmissionResult emissionResult : emissionResults) {
            if (emissionResult.getEmissionWay() == 1) {
                emissionResult.setEmissionWays("物料衡算法");
            } else if (emissionResult.getEmissionWay() == 2) {
                emissionResult.setEmissionWays("产排污系数法");
            } else {
                emissionResult.setEmissionWays("实测法");
            }
        }
        dataMap.put("emissionResults", emissionResults);


        //获取拟实施措施
        List<TMeasuresResult> measuresResults = measuresService.getMeasureList(companyId);
        for (TMeasuresResult measuresResult : measuresResults) {
            if (measuresResult.getRedType() == 1) {
                measuresResult.setRedTypes("源头替代");
            } else if (measuresResult.getRedType() == 2) {
                measuresResult.setRedTypes("过程控制");
            } else {
                measuresResult.setRedTypes("末端治理");
            }

            if (measuresResult.getMeasureType() == 1) {
                measuresResult.setMeasureTypes("强制性措施");
            } else {
                measuresResult.setMeasureTypes("推荐性措施");
            }
        }
        dataMap.put("measuresResults", measuresResults);
        TMeasuresResult tMeasuresResult = measuresService.measureHeadInfo(companyId);
        dataMap.put("totalMeasure", tMeasuresResult.getTotalMeasure());

        //获取台账管理信息
        List<VocManagementLedgerResult> ledgerResults = ledgerService.getLedgerLists(companyId);
        for (VocManagementLedgerResult ledgerResult : ledgerResults) {
            if (ledgerResult.getIsPerfect() == 0) {
                ledgerResult.setIsPerfects("完善");
                ledgerResult.setReason("已完善");
            } else {
                ledgerResult.setIsPerfects("未完善");
            }
        }
        dataMap.put("ledgerResults", ledgerResults);


        //获取排放量汇总表数据
        VocsEmissionResult vocsEmissionResult = emissionService.getEmissionSummarys(companyId);

        dataMap.put("vocsEmissionResult", vocsEmissionResult);

        //系统时间
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        String date = df.format(new Date());
        dataMap.put("downDate", date);

        return dataMap;
    }

    @Value("${download.word.template}")
    private String templatePath;

    @Value("${download.word.download}")
    private String downloadPath;

    @Override
    public ResponseData exportData(Integer companyId, HttpServletRequest request, HttpServletResponse response) {
        TCommitReport commitReport = commitReportService.getDetailByCid(companyId);
        if (ToolUtil.isEmpty(commitReport)) {
            return ResponseData.error("公司数据丢失");
        }

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");
        Map<String, Object> params = new HashMap<>();
        params.put("compellation", "18756096778");
        params.put("sex", "男");
        params.put("age", 12);
        params.put("testTime", simpleDateFormat.format(new Date()));
        params.put("testNumber", "111");
        params.put("testObject", "111");

        params.put("oneExam", "111");
        params.put("oneResult", "111");
        params.put("oneGrade", "111");
        params.put("twoExam", "111");
        params.put("twoResult", "111");
        params.put("twoGrade", "111");
        params.put("threeExam", "111");
        params.put("threeResult", "111");
        params.put("threeGrade", "111");
        params.put("fourExam", "111");
        params.put("fourResult", "111");
        params.put("fourGrade", "111");
        params.put("fiveExam", "111");
        params.put("fiveResult", "111");
        params.put("fiveGrade", "111");

        params.put("score", "111");
        params.put("grade", "111");

        log.info("*********模板地址为:" + templatePath);
        log.info("*********下载地址为:" + downloadPath);

        ExportWordUtils.exportWord(templatePath + "体育锻炼标准评估报告模板.docx", downloadPath, "体育锻炼标准评估报告.docx", params, request, response);
        return ResponseData.success();
    }

}
